#ifndef HASH_H
#define HASH_H

/************
 * 采用 链地址法 处理哈希冲突
 * 
 * 
 */

#include <stdlib.h>
#include <string.h>

typedef struct HashNode
{
    void *key;
    void *value;
    struct HashNode* next;
}HashNode;

typedef struct HashTable
{
    HashNode **table;
    int capacity;//容量
    int size;    //元素数量
}HashTable;

typedef unsigned int(*hash_function)(const void *key, int capacity);
extern hash_function g_hash_func;

typedef int (*hash_compare)(void *key1,void *key2);
extern hash_compare g_compare;

HashTable *hash_table_init(int initial_capacity);
int hash_table_clear(HashTable* table);

int hash_insert(HashTable* table,void *key,int keylen,void* value,int vlen);
HashNode* hash_get(HashTable* table,void *key);
int hash_modify(HashTable* table,void *key,int keylen,void* value,int vlen);
int hash_delete(HashTable* table,void *key);

#endif